/****************************************************************************
 *   This file is part of Q2D.                                              *
 *                                                                          *
 *   Q2D is free software: you can redistribute it and/or modify            *
 *   it under the terms of the GNU General Public License as published by   *
 *   the Free Software Foundation, either version 3 of the License, or      *
 *   (at your option) any later version.                                    *
 *                                                                          *
 *   Q2D is distributed in the hope that it will be useful,                 *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *   GNU General Public License for more details.                           *
 *                                                                          *
 *   You should have received a copy of the GNU General Public License      *
 *   along with Q2D.  If not, see <http://www.gnu.org/licenses/>.           *
 *                                                                          *
 ****************************************************************************/

#ifndef MYSQLEMBEDDEDDATABASE_H
#define MYSQLEMBEDDEDDATABASE_H

#include <QtCore/QCoreApplication>
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlDriver>
#include <QtSql/QSqlQuery>
#include <QtCore/QFile>
#include <QtCore/QVariant>
#include <QtCore/QDir>
#include <QtCore/QList>

#include "weapon/weapon.h"
#include "weapon/weapondamagetype.h"
#include "weapon/weapontype.h"

class MySQLEmbeddedDatabase: public QObject
{
        Q_OBJECT
        Q_DISABLE_COPY(MySQLEmbeddedDatabase)
public:
    MySQLEmbeddedDatabase();
    ~MySQLEmbeddedDatabase();

    bool addWeapon(Weapon *weapon);
    bool removeWeapon(Weapon *weapon);
    bool removeWeapon(QString hash);
    bool removeWeapon(uint hash);
    bool updateWeapon(Weapon *weapon);
    bool getWeapon(uint id, Weapon *weapon);
    bool getWeapon(QString hash, Weapon *weapon);
    bool weaponExist(Weapon weapon);
    QList<Weapon> getAllWeapons();

    bool addWeaponType(WeaponType *type);
    bool removeWeaponType(WeaponType *type);
    bool removeWeaponType(QString hash);
    bool removeWeaponType(uint id);
    bool updateWeaponType(WeaponType *type);
    bool getWeaponType(uint id, WeaponType *type);
    bool getWeaponType(QString hash, WeaponType *type);
    bool weaponTypeExist(WeaponType type);

    bool addWeaponDamageType(WeaponDamageType *type);
    bool removeWeaponDamageType(WeaponDamageType *type);
    bool removeWeaponDamageType(QString hash);
    bool removeWeaponDamageType(uint id);
    bool updateWeaponDamageType(WeaponDamageType *type);
    bool getWeaponDamageType(uint id, WeaponDamageType *type);
    bool getWeaponDamageType(QString hash, WeaponDamageType *type);
    bool weaponDamageTypeExist(WeaponDamageType type);

private:
    QSqlDatabase db;

    void createDatabase(void);
};

#endif // MYSQLEMBEDDEDDATABASE_H
